package com.hans.scala

/**
 * User: ZhangJuntao
 * Date: 14-3-14
 * Time: 下午4:19
 */
object MultiTable {


  def main(args: Array[String]) {
    println(multiTable())
  }

  def multiTable() = {
    def makeRowSeq(row: Int) = for (col <- 1 to row) yield {
      val prod = col + "*" + row + "=" + (row * col).toString
      val padding = " " * (10 - prod.length)
      padding + prod
    }

    def makeRow(row: Int) = makeRowSeq(row).mkString

    val tableSeq =
      for (row <- 1 to 10)
      yield makeRow(row)
    tableSeq.mkString("\n")
  }
}
